package com.zxy.supplier_system.server.controller

import com.zxy.supplier_system.server.entity.Authority
import com.zxy.supplier_system.server.service.DirectSaleOrderService
import com.zxy.supplier_system.server.utils.IntIdAndName
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Slice
import org.springframework.web.bind.annotation.*
import java.time.OffsetDateTime

@RestController
@RequestMapping("directSaleClients/{directSaleClientId}/orders")
class DirectSaleClientsOrderController(
    private val directSaleClientService: DirectSaleOrderService
) {

    @HasAnyAuthority(Authority.卖场_订单_下单)
    @PostMapping
    fun createDirectSaleClientOrder(@PathVariable directSaleClientId: Int):Int{
        return this.directSaleClientService.createDirectSaleOrder(directSaleClientId)
    }

    @HasAnyAuthority(Authority.卖场_订单_查询)
    @GetMapping
    fun queryDirectSaleClientOrderInDirectSaleClient(@PathVariable directSaleClientId: Int,pageable: Pageable):Slice<QueryDirectSaleClientOrderInDirectSaleClientResponse>{
        return this.directSaleClientService.queryDirectSaleOrderInClient(directSaleClientId,pageable)
    }

    data class QueryDirectSaleClientOrderInDirectSaleClientResponse(
        val id:Int,
        val createdBy: IntIdAndName,
        val createdDateTime: OffsetDateTime,
        val goodsKindAmount:Int,
        val submittedDateTime:OffsetDateTime?
    )



}